Skip to content

Tests: the allocation probes read a column of ints that does not box - #301

Merged
electricessence merged 1 commit into
masterfrom
tests/probe-no-boxing
Dec 2, 2026
Merged

electricessence merged 1 commit into
masterfrom
tests/probe-no-boxing

Conversation

@electricessence

@electricessence electricessence commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Tests only. SyncToListAllocationProbe (100,000 rows) failed now and then: the chain allocated 2,800,784 bytes against 1,049,704 for the list that grows. The gap is exactly 24 bytes a row: a DataTableReader boxes each int it reads until the JIT has optimized the read. The probe measured the chain first and the list second, so when the optimization landed between the two measurements the chain paid for the boxes and the list did not. The pool and the library were not involved.

The fix

Both probes that read a DataTable (the synchronous ToList, and the reader's ToArrayAsync and ToImmutableArrayAsync) now read an in-memory reader of one int column, Int32ColumnReader, whose typed getter allocates nothing, as a provider's does. The count no longer depends on when the JIT tiers up. The threshold is unchanged. The reader is a TypedReader over a column made once (Int32Column), so a call allocates only the reader.

Checks

  • Over 100,000 rows the probe prints the same counts with default settings, with DOTNET_TieredCompilation=0 and with DOTNET_TC_CallCountingDelayMs=2000: ToList 400,136 bytes, the growing list 1,049,032, ToArray 400,104. The asserting probes pass 3 of 3 under each of default, TieredCompilation=0, TieredPGO=0 and a late tier-up.
  • The old probes do not fail under those settings alone: with tiering off, both sides box equally and the chain is still smaller. They fail only when the tier-up lands between the two measurements, so a "fails before" run cannot be forced with an environment variable. The identical counts under the three settings are the proof that the count no longer depends on it.
  • Release 15,990 and Debug 15,969 tests pass (16 skipped), 0 build warnings, 255 sample checks, VS MSBuild 0 errors, dotnet format style and analyzers clean on all 28 checks, DocFX 0 warnings.

Other allocation tests also read a DataTableReader, but they assert a fixed bound on one measurement, not a comparison of two measured sides, so a tier-up between measurements does not flip them; none has flaked and they are left alone.

🤖 Generated with Claude Code

SyncToListAllocationProbe failed now and then (the chain 2,800,784 bytes,
the list that grows 1,049,704). The difference is exactly 24 bytes a row:
a DataTableReader boxes each int it reads until the JIT has optimized the
read, and the probe measured the chain before the list, so when the
optimization landed between the two measurements the chain paid for the
boxes and the list did not. The pool and the library were not involved.

Both probes that read a DataTable (the synchronous ToList and the reader's
ToArrayAsync and ToImmutableArrayAsync) now read an in-memory reader of one
int column whose typed getter allocates nothing, as a provider's does, so
the count no longer depends on when the JIT tiers up. The threshold is
unchanged. Over 100,000 rows the same counts come out with default
settings, with TieredCompilation off and with tier-up delayed (the chain
400,136 bytes, the growing list 1,049,032).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@electricessence
electricessence merged commit eb30290 into master Dec 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant